{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pymssql\n",
    "import pandas as pd\n",
    "from sqlalchemy import create_engine"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "连接成功!\n"
     ]
    }
   ],
   "source": [
    "\n",
    "connect = pymssql.connect('192.168.3.112', 'sa', 'taotao778899!', 'DB_INFORMATION', charset='utf8')  #建立连接\n",
    "if connect:\n",
    "    print(\"连接成功!\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {},
   "outputs": [],
   "source": [
    "sql = \"select top 10 * from SECURITIES_INNERCODE where TradingCode in ('002459', '600685')\"\n",
    "df0 = pd.read_sql(sql,connect)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 35,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>InnerCode</th>\n",
       "      <th>TradingCode</th>\n",
       "      <th>SecuAbbr</th>\n",
       "      <th>ChiSpelling</th>\n",
       "      <th>SecuCategory</th>\n",
       "      <th>SecuCategoryCodeII</th>\n",
       "      <th>ExchangeCode</th>\n",
       "      <th>ExchangeName</th>\n",
       "      <th>ListingStateCode</th>\n",
       "      <th>CreateOn</th>\n",
       "      <th>LastUpdateOn</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>967</td>\n",
       "      <td>002459</td>\n",
       "      <td>¾§°Ä¿Æ¼¼</td>\n",
       "      <td>JAKJ</td>\n",
       "      <td>A¹É</td>\n",
       "      <td>1001</td>\n",
       "      <td>105</td>\n",
       "      <td>ÉîÛÚÖ¤È¯½»Ò×Ëù</td>\n",
       "      <td>1</td>\n",
       "      <td>2020-07-29 14:05:27.613</td>\n",
       "      <td>2021-09-28 15:11:13.020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>55652</td>\n",
       "      <td>002459</td>\n",
       "      <td>»ªÏÄ¶¦ÀûÕ®È¯·¢ÆðÊ½A</td>\n",
       "      <td>HXDLZQFQSA</td>\n",
       "      <td>·Ç»õ±ÒÐÍ</td>\n",
       "      <td>1019</td>\n",
       "      <td>999</td>\n",
       "      <td>³¡Íâ»ù½ð</td>\n",
       "      <td>1</td>\n",
       "      <td>2020-07-29 14:05:27.613</td>\n",
       "      <td>2021-09-28 15:11:13.020</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3301</td>\n",
       "      <td>600685</td>\n",
       "      <td>ÖÐ´¬·ÀÎñ</td>\n",
       "      <td>ZCFW</td>\n",
       "      <td>A¹É</td>\n",
       "      <td>1001</td>\n",
       "      <td>101</td>\n",
       "      <td>ÉÏº£Ö¤È¯½»Ò×Ëù</td>\n",
       "      <td>1</td>\n",
       "      <td>2020-07-29 14:05:27.613</td>\n",
       "      <td>2021-09-28 15:11:13.020</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   InnerCode TradingCode             SecuAbbr ChiSpelling SecuCategory  \\\n",
       "0        967      002459             ¾§°Ä¿Æ¼¼        JAKJ          A¹É   \n",
       "1      55652      002459  »ªÏÄ¶¦ÀûÕ®È¯·¢ÆðÊ½A  HXDLZQFQSA     ·Ç»õ±ÒÐÍ   \n",
       "2       3301      600685             ÖÐ´¬·ÀÎñ        ZCFW          A¹É   \n",
       "\n",
       "   SecuCategoryCodeII  ExchangeCode    ExchangeName  ListingStateCode  \\\n",
       "0                1001           105  ÉîÛÚÖ¤È¯½»Ò×Ëù                 1   \n",
       "1                1019           999        ³¡Íâ»ù½ð                 1   \n",
       "2                1001           101  ÉÏº£Ö¤È¯½»Ò×Ëù                 1   \n",
       "\n",
       "                 CreateOn            LastUpdateOn  \n",
       "0 2020-07-29 14:05:27.613 2021-09-28 15:11:13.020  \n",
       "1 2020-07-29 14:05:27.613 2021-09-28 15:11:13.020  \n",
       "2 2020-07-29 14:05:27.613 2021-09-28 15:11:13.020  "
      ]
     },
     "execution_count": 35,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
